package com.xunk.common.core.enums.dnake;


import com.xunk.common.core.interfaces.EnumValidateInterface;

/**
 * @Author: wangTong
 * @Description: 狄耐克错误码枚举
 * @Date: 2021/5/12 10:50
 * @Version: 1.0
 */
public enum DnakeErrnoEnum implements EnumValidateInterface {

    OK(0, "正确"),
    UNKNOWN(101, "未知错误"),
    FORMATERR(102, "协议格式错误"),
    PARAERR(103, "传递参数错误"),
    NOEXIST(104, "操作对象不存在"),
    HOLDON(105, "重复操作请稍等"),
    NOREADY(106, "未准备就绪"),
    NOAUTHORITY(107, "无操作权限"),
    OFFLINE(108, "设备处于离线状态"),
    OVERTIME(109, "操作超时"),
    DEVICETYPEERR(110, "设备类型错误"),
    DEVICEALREADYEXIST(111, "设备已存在"),
    ZIGBEEOFFLINE(112, "网关的 zigbee 不在线，无法添加设备"),
    ZIGBEENORESPONSE(113, "入网的 zigbee 设备端点请求无响应"),
    ZIGBEEDESCRIPTORNORESPONSE(114, "入网的 zigbee 设备端点描述符请求无响应"),
    TEMPERATURENORESPONSE(115, "入网的温湿度传感器配置温度属性无响应"),
    HUMIDITYNORESPONSE(116, "入网的温湿度传感器配置湿度属性无响应"),
    ELECTRICITYNORESPONSE(117, "入网的温湿度传感器配置电量属性无响应"),
    REPEAT(118, "重复操作，如收到一样的场景时会提示重复操作"),
    SWITCHNORESPONSE(119, "入网时配置立达信彩色灯的开关属性无响应"),
    COLORNORESPONSE(120, "入网时配置立达信彩色灯的颜色属性无响应"),
    BRIGHTNESSNORESPONSE(121, "入网时配置立达信彩色灯的亮度属性无响应"),
    OVERSTEP(122, "设备数量超出"),
    NOSUPPORT(123, "操作不支持"),
    UDIDFAIL(124, "Udid 校验失败"),
    TOPICFAIL(125, "Topic 校验失败"),
    BUSY(126, "设备忙"),
    NOFIND(127, "没有找到对应红外码库");

    private Integer code;
    private String desc;

    DnakeErrnoEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code){
        for(DnakeErrnoEnum dnakeActionEnum : DnakeErrnoEnum.values()){
            if(dnakeActionEnum.getCode() == code.intValue()){
                return dnakeActionEnum.getDesc();
            }
        }
        return null;
    }

    /**
     * 判断是否是可用枚举
     *
     * @param code
     * @return
     */
    @Override
    public Boolean isValidEnum(String code) {
        for (DnakeErrnoEnum value : DnakeErrnoEnum.values()) {
            if (value.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
